package com.xuetang9.demo.ssm.domain;

import java.io.Serializable;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

import org.hibernate.validator.constraints.NotBlank;
import com.xuetang9.demo.ssm.domain.validation.Insert;
import com.xuetang9.demo.ssm.domain.validation.Update;

@SuppressWarnings("serial")
public class Resource implements Serializable {

	@NotNull(message = "{resource.id.required}", groups = { Update.class })
	private Integer id;

	@NotBlank(message = "{resource.name.required}", groups = { Insert.class, Update.class })
	private String name;

	@Pattern(regexp="fa-(.{1,})",message="字体图标的格式为 fa-名称 ",groups = { Insert.class, Update.class })
	private String icon;
	
	private String url;
		
	private Integer type;

	@NotNull(message = "父级资源编号不能为空", groups = { Insert.class, Update.class })
	@org.hibernate.validator.constraints.Range(min = 0, message = "父级编号最小为0", groups = { Insert.class, Update.class })
	private Integer pid;
	private Integer sort;
	private String description;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public Integer getPid() {
		return pid;
	}

	public void setPid(Integer pid) {
		this.pid = pid;
	}

	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Override
	public String toString() {
		return "Resource [id=" + id + ", name=" + name + ", icon=" + icon + ", url=" + url + ", type=" + type + ", pid="
				+ pid + ", sort=" + sort + ", description=" + description + "]";
	}
	
	public static void main(String[] args) {
		
		System.out.println(java.util.regex.Pattern.matches("fa-(.{1,})", "fa-uasdad"));
	}

}
